/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit.ieproject.utilites;

import java.io.File;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JProgressBar;
import javax.swing.JTextArea;
import javax.swing.text.DefaultCaret;
import uit.ieproject.entities.Person;
import uit.ieproject.presentation.MainFrame;

/**
 *
 * @author Maivia
 */
public class StatusThread implements Runnable {

    public int numFiles;
    public JProgressBar pbStatus;
    public JTextArea taStatus;
    public DefaultListModel extractListModel;
    public static Person person;
    public File file;

    public StatusThread(JProgressBar pbStatus, JTextArea taStatus, DefaultListModel extractListModel, int numFiles) {
        this.numFiles = numFiles;
        this.file = file;
        this.pbStatus = pbStatus;
        this.taStatus = taStatus;
        this.extractListModel = extractListModel;

        DefaultCaret caret = (DefaultCaret) taStatus.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    }

    @Override
    public void run() {
        /*try {
            while (MainFrame.num_extract_file < numFiles) {
                int currentValue = MainFrame.num_extract_file + (100 / numFiles);
                pbStatus.setValue(currentValue);
                //taStatus.append("Tập tin " + file.getName() + " đã rút trích xong!\n");
                //taStatus.append("Thông tin nhân vật " + person.getName() + " đã được lưu lại!\n");
                //taStatus.append("...................\n");
                extractListModel.addElement(person.getName());
                if (MainFrame.isStopped) {
                    taStatus.append("Dừng quá trình rút trích!!!");
                    break;
                }
                if (MainFrame.num_extract_file == numFiles - 1) {
                    pbStatus.setValue(100);
                    taStatus.append("Quá trình rút trích hoàn tất!!!");
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }*/
    }
}
